package com.sea.demo.shiro.service.impl;

import com.github.pagehelper.PageHelper;
import com.sea.demo.shiro.domain.Permission;
import com.sea.demo.shiro.mapper.PermissionMapper;
import com.sea.demo.shiro.service.PermissionService;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @Author: 快乐在角落里
 * @Create: 2020/11/8 2:17
 */
@Service
public class PermissionServiceImpl implements PermissionService {

    private final PermissionMapper permissionMapper;

    public PermissionServiceImpl(PermissionMapper permissionMapper) {
        this.permissionMapper = permissionMapper;
    }

    @Override
    public int insert(Permission permission) {
        return permissionMapper.insert(permission);
    }

    @Override
    public int delete(Integer id) {
        return permissionMapper.delete(id);
    }

    @Override
    public int update(Permission permission) {
        return permissionMapper.update(permission);
    }

    @Override
    public List<Permission> select(Permission permission) {
        return select(permission,null,null);
    }

    @Override
    public List<Permission> select(Permission permission, Integer currentPage, Integer pageSize) {
        return select(permission,currentPage,pageSize,null);
    }

    @Override
    public List<Permission> select(Permission permission, Integer currentPage, Integer pageSize, String orderBy) {
        PageHelper.startPage(currentPage,pageSize,orderBy);
        return permissionMapper.select(permission);
    }

    @Override
    public Permission selectOne(Integer id) {
        return permissionMapper.selectOne(id);
    }
}
